<?php

class CMS_Models_LangWeb extends Zend_Db_Table_Abstract {

    protected $_name = "lang_web";

    public function __construct() {
        parent::__construct(array('table' => $this->_name));
    }

    public function getAll() {
        $contact = $this->fetchAll();
        return $contact;
    }

    public function getWebByLang($lang) {

        $query = $this->select($this->_name.".*")
                  ->setIntegrityCheck(false)
                  ->join("web","web.id = ".$this->_name.".id_web", array("author" => "author", "copyright" => "copyright", "id" => "id"))
                  ->where($this->_name.".lang = '$lang' ");
       return $this->fetchAll($query);
    }

    /*
     * devuelve el contenido, asociado a los datos de la tabla content
     */

    public function getWebByKey($id, $lang) {

        $query = $this->select($this->_name.".*")
                  ->setIntegrityCheck(false)
                  ->join("web","web.id = ".$this->_name.".id_web",  array("author" => "author", "copyright" => "copyright", "id" => "id"))
                  ->where($this->_name.".lang = '$lang' ")
                  ->where("web.id = $id");
        //echo $query; exit;
        return $this->fetchRow($query);
    }

    /**
     * Devuelve el  contenido para obtener el registro de la tabla
     * @param unknown_type $id
     */
    public function getWebById($id, $lang) {
        $web = $this->fetchRow("id_web = '$id' and lang = '$lang'");
        return $web;
    }

}